/**
 * @param {character[][]} board
 * @return {boolean}
 */
var isValidSudoku = function (board) {
  let row = new Array(9).fill(0).map(() => (new Array(9).fill(0)))
  let col = new Array(9).fill(0).map(() => (new Array(9).fill(0)))
  let grid = new Array(3).fill(0).map(() => (new Array(3).fill(0).map(() => new Array(9).fill(0))))
  for (let i = 0; i < 9; i++) {
    for (let j = 0; j < 9; j++) {
      if (board[i][j] != '.') {
        const c = board[i] - 1
        row[i][c]++
        col[j][c]++
        grid[Math.floor(i / 3)][Math.floor(j / 3)][c]++
        if (row[i][c] > 1 || col[j][c] > 1 || grid[Math.floor(i / 3)][Math.floor(j / 3)][c] > 1) {
          return false
        }
      }
    }
  }
  return true
};